<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改单据')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-doc-edit" th:object="${busTransportationDoc}">
            <input id="dId" name="dId" th:field="*{dId}"  type="hidden">
            <div class="form-group">
                <label class="col-sm-2 control-label">日期：</label>
                <div class="col-sm-10 input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text" class="form-control" id="datetimepicker-demo-2" name="docDate" placeholder="请输入日期" th:value="${#dates.format(busTransportationDoc.docDate,'yyyy-MM-dd')}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">时间段：</label>
                <div class="col-sm-10">
                    <div class="radio-box" th:each="dict : ${@dict.getType('trans_time')}">
                        <input type="radio" th:id="${dict.dictCode}" name="docTime" th:value="${dict.dictValue}" th:field="*{docTime}">
                        <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">供应商：</label>
                <div class="col-sm-10">
                    <select id="supplier" class="form-control select2-multiple" multiple>
                        <option th:each="supp:${suppliers}" th:value="${supp.sId}" th:text="${supp.name}" th:selected="${supp.flag}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">车牌：</label>
                <div class="col-sm-10">
                    <input id="licensePlate" name="licensePlate" class="form-control" type="text" th:field="*{licensePlate}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">司机：</label>
                <div class="col-sm-10">
                    <input id="driver" name="driver" class="form-control" type="text" th:field="*{driver}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">电话号码：</label>
                <div class="col-sm-10">
                    <input id="phone" name="phone" class="form-control" type="text" placeholder="请输入手机号码" maxlength="11" th:field="*{phone}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">商品：</label>
                <div class="col-sm-10">
                    <input id="goods" name="goods" class="form-control" type="text"  th:field="*{goods}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">数量：</label>
                <div class="col-sm-10">
                    <input id="quantity" name="quantity" class="form-control" type="text" th:field="*{quantity}">
                </div>
            </div>
		</form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">
        var prefix = ctx + "trans/doc";
        $(function(){
            $("#datetimepicker-demo-2").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });

            $('#supplier').select2({
                placeholder: "请选择岗位",
                allowClear: true
            });
        });
		$("#form-doc-edit").validate({
			focusCleanup: true
		});
		function submitHandler() {
	        if ($.validate.form()) {
                var data = $("#form-doc-edit").serializeArray();
                var supplier = $.form.selectSelects("supplier");
                data.push({"name": "supplier", "value": supplier});
				$.operate.save(prefix + "/edit", data);
	        }
	    }
	</script>
</body>
</html>
